﻿using Ardalis.GuardClauses;
using HRX.PayCenter.Contract;
using System;
using System.Collections.Generic;
using System.Text;

namespace HRX.PayCenter.ApplicationCore.Exceptions
{
    /// <summary>
    /// 
    /// </summary>
    public static class GuardExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="guardClause"></param>
        /// <param name="message"></param>
        public static void NullException(this IGuardClause guardClause, string message = "参数不能为null")
        {
            throw new PayCenterException((int)ResultCode.数据不可为空, message);
        }

        /// <summary>
        /// 验证异常
        /// </summary>
        /// <param name="guardClause"></param>
        /// <param name="message"></param>
        public static void VaildException(this IGuardClause guardClause, string message)
        {
            throw new PayCenterException((int)ResultCode.参数验证失败, message);
        }

        /// <summary>
        /// 业务异常
        /// </summary>
        /// <param name="guardClause"></param>
        /// <param name="code"></param>
        /// <param name="message"></param>
        public static void BizException(this IGuardClause guardClause, ResultCode code, string message)
        {
            throw new PayCenterException((int)code, message);
        }
    }
}
